﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Groep8
{

    public partial class Festivals : Page
    {
        private DataTable dtFestivals;
        DataAccessLayer d;
        // Uitvoeren stored procedure via de DataAccessLayer om de lijst van festivals op te halen.
        protected void Page_Load(object sender, EventArgs e)
        {
            d = new DataAccessLayer();
            dtFestivals = d.Select("procedure_select_festivals");
            FestivalsGrid.DataSource = dtFestivals;
            FestivalsGrid.DataBind();

        }
        // Regelt het sorteren van de lijst van Festivals.
        protected void FestivalsGrid_Sorting(object sender, GridViewSortEventArgs e)
        {
            switch (e.SortExpression)
            {
                case "fest_naam":
                    if (e.SortDirection == SortDirection.Ascending)
                    {
                        FestivalsGrid.DataSource = d.SelectWithParam("procedure_select_festivals_sort", 1);
                        FestivalsGrid.DataBind();
                    }
                    break;
                case "fest_datum":
                    if (e.SortDirection == SortDirection.Ascending)
                    {
                        FestivalsGrid.DataSource = d.SelectWithParam("procedure_select_festivals_sort", 2);
                        FestivalsGrid.DataBind();
                    }
                    break;

            }
        }
        }
    }
